<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<!DOCTYPE html>
<html>
<head>
    <title>Sherlock: Results</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <link rel="stylesheet" href="/css/main.css" type="text/css"/>
    <link rel="stylesheet" href="/css/results.css" type="text/css">
    <link rel="stylesheet" href="/css/registration-login.css" type="text/css"/>
    <script src="/script/lib/jquery-1.10.2.js"></script>
    <script src="/script/main.js"></script>
    <script src="/script/login.js"></script>
    <script src="/script/registration.js"></script>
</head>
<body>

<c:import url="fragments/header.jsp"/>

<div id="res-header">
    <span id="res-search">
        <img id="res-image" src="/img/logo2.png"/>

        <form id="res-search-form" action="/search">
            <input id="res-query" name="query" type="text"/>
            <input id="res-submit" type="submit"/>
        </form>
    </span>
</div>

<div style="padding-bottom: 15px;">
    <c:if test="${not empty error}">
        An error occurred
    </c:if>
    <c:if test="${not empty noDocumentsIndexed}">
        No documents indexed, please contact admin
        <a href="<%= request.getContextPath() %>/admin">here</a>.
    </c:if>
    <c:choose>
        <c:when test="${totalResults == 0}">
            No documents found
        </c:when>
        <c:otherwise>
            <c:forEach items="${results}" var="result">
                <div class="res-item">
                    <a href="${result.url}">${result.title}</a>
                    <p>${result.url}</p>
                    <p>${result.summary}</p>
                </div>
            </c:forEach>

            <c:if test="${previousURL != null || nextURL != null}">
                <span class="res-nav-bar">
                <c:if test="${previousURL != null}">
                    <a href="${previousURL}">
                        Previous ${maxResultsPerPage} results
                    </a>
                </c:if>
                <c:if test="${previousURL != null && nextURL != null}">
                    &nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
                </c:if>
                <c:if test="${nextURL != null}">
                    <a href="${nextURL}">
                        Next ${maxResultsPerPage} results
                    </a>
                </c:if>
                </span>
            </c:if>
        </c:otherwise>
    </c:choose>
</div>

<c:import url="fragments/registration-window.jsp"/>
<c:import url="fragments/login-window.jsp"/>

</body>
</html>